package com.py.custom.business.demo.core.utils;

import java.util.Map;

public class MessageProcessUtils {

    public static String process(String variableValue, String content,
                                 Map<String, String> map) {
        String[] keys = variableValue.split(",");
        for (String key : keys) {
            String value = map.get(key);
            String valueKey = "${" + key + "}";
            content = content.replace(valueKey, value);
        }
        return content;
    }

    public static Integer processStatus(Integer code) {
        if (code == 0) {
            // 成功
            return 1;
        } else if (code == 1) {
            // 外部平台已接收，但是消息发送失败
            return 2;
        } else if (code == 2) {
            // 外部平台服务异常
            return 3;
        }
        return null;
    }
}
